﻿@{
    ViewBag.Title = "Item Details";
    ViewBag.HomeActive = "active";
}

@model Sweepids.Models.Object.Item

@{
    var savings = (int) (100 * (1 - (Model.Price / Model.OriginalPrice)));
}

@if (TempData["Error"] != null)
{
    <div class="alert alert-error">
        @TempData["Error"]
    </div>
}

@if (TempData["Success"] != null)
{
    <div class="alert alert-success">
        @TempData["Success"]
    </div>
}

<div id="sweep_content">
    <div id="item_detail" class="well span6">

        <h3>@Model.Name <span style="color: firebrick; font-size: 20px;">Save @savings%</span></h3>

        @if (Model.EndTime.CompareTo(DateTime.Now) < 0)
        {
            <p class="text-warning">This item has expired.</p>
            if (Model.WinUser != "")
            {     
            <p class="text-success">Won by @Model.WinUser</p>
            }
        }

        <p>@Model.Description</p>
        
        @if (Model.Photo == "")
        {
            <img src="http://bookstore.bastyr.edu/images/thumbs/noDefaultImage_300.gif" alt="Default Image" width="300" height="300"/>
        }
        else
        {
            <img src="@Model.Photo" alt="Image of the item" style="max-width: 300px; height: 300px"/>
        }

        <dl class="dl-horizontal">
            <dt>Original Price: </dt>
            <dd><del>@String.Format("{0:C}", Model.OriginalPrice)</del></dd>
            <dt>Price: </dt>
            <dd>@String.Format("{0:C}", Model.Price)</dd>
            <dt>Category: </dt>
            <dd>@Model.CategoryObj.Name</dd>
            <dt>Start Time: </dt>
            <dd>@Model.StartTime</dd>
            <dt>End Time: </dt>
            <dd>@Model.EndTime</dd>
            <dt>Sweeps on Item: </dt>
            <dd>@Model.SweepsOnItem</dd>
        </dl>

        @if (Model.EndTime.CompareTo(DateTime.Now) > 0)
        {
            <p class="lead">Bid on this item</p>
            <form class="form-inline" action="~/ItemDetail/PlaceBid" method="POST">
                <input type="hidden" name="itemId" value="@Model.Id" />
                <input type="text" name="sweeps" placeholder="Number of Sweeps" pattern="\d+" title="Enter positive integer" />
                <button type="submit" class="btn btn-primary">Bid</button>
            </form>
        }
    </div>
</div>
